package coms.mianshi.equals;

/**
 * @program: item_02
 * @description: euqalTest
 * @author: LL
 * @create: 2021-03-02 11:19
 */
public class EqualsTest {


    public static void main(final String[] args) {

    }


}

class Coder {
    private String name;
    private int age;

    public Coder() {
        super();
    }

    public Coder(final String name, final int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return this.name;
    }

    public void setName(final String name) {
        this.name = name;
    }

    public int getAge() {
        return this.age;
    }

    public void setAge(final int age) {
        this.age = age;
    }

    @Override
    public boolean equals(final Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof Coder)) {
            return false;
        }
        final Coder coder = (Coder) obj;

        return coder.name.equals(this.name) && coder.age == this.age;
    }

    @Override
    public int hashCode() {
        int result = 17;
        result = result * 31 + this.name.hashCode();
        result = result * 31 + this.age;

        return result;
    }
}
